home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RCS_56.ARJ / RCSFREEZ.SH < prev    next >
Linux/UNIX/POSIX Shell Script  |  1992-02-11  |  3KB  |  101 lines

  1. #! /bin/sh
  2.  
  3. # rcsfreeze - assign a symbolic revision number to a configuration of RCS files
  4.  
  5. #    $Id: rcsfreeze.sh,v 4.4 1991/04/21 11:58:24 eggert Exp $
  6.  
  7. #       The idea is to run rcsfreeze each time a new version is checked
  8. #       in. A unique symbolic revision number (C_[number], where number
  9. #       is increased each time rcsfreeze is run) is then assigned to the most
  10. #       recent revision of each RCS file of the main trunk.
  11. #
  12. #       If the command is invoked with an argument, then this
  13. #       argument is used as the symbolic name to freeze a configuration.
  14. #       The unique identifier is still generated
  15. #       and is listed in the log file but it will not appear as
  16. #       part of the symbolic revision name in the actual RCS file.
  17. #
  18. #       A log message is requested from the user which is saved for future
  19. #       references.
  20. #
  21. #       The shell script works only on all RCS files at one time.
  22. #       It is important that all changed files are checked in (there are
  23. #       no precautions against any error in this respect).
  24. #       file names:
  25. #       {RCS/}.rcsfreeze.ver    version number
  26. #       {RCS/}.rscfreeze.log    log messages, most recent first
  27.  
  28. PATH=/usr/local/bin:/bin:/usr/bin:/usr/ucb:$PATH
  29. export PATH
  30.  
  31. DATE=`date` || exit
  32. # Check whether we have an RCS subdirectory, so we can have the right
  33. # prefix for our paths.
  34. if [ -d RCS ]
  35. then RCSDIR=RCS/
  36. else RCSDIR=
  37. fi
  38.  
  39. # Version number stuff, log message file
  40. VERSIONFILE=${RCSDIR}.rcsfreeze.ver
  41. LOGFILE=${RCSDIR}.rcsfreeze.log
  42. # Initialize, rcsfreeze never run before in the current directory
  43. [ -r $VERSIONFILE ] || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit
  44.  
  45. # Get Version number, increase it, write back to file.
  46. VERSIONNUMBER=`cat $VERSIONFILE` &&
  47. VERSIONNUMBER=`expr $VERSIONNUMBER + 1` &&
  48. echo $VERSIONNUMBER >$VERSIONFILE || exit
  49.  
  50. # Symbolic Revision Number
  51. SYMREV=C_$VERSIONNUMBER
  52. # Allow the user to give a meaningful symbolic name to the revision.
  53. SYMREVNAME=${1-$SYMREV}
  54. echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\"
  55. rcsfreeze: symbolic revision number used:     \"${SYMREVNAME}\"
  56. rcsfreeze: the two differ only when rcsfreeze invoked with argument
  57. rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \
  58.     || exit
  59.  
  60. # Stamp the logfile. Because we order the logfile the most recent
  61. # first we will have to save everything right now in a temporary file.
  62. TMPLOG=/tmp/rcsfrz$$
  63. trap 'rm -f $TMPLOG; exit 1' 1 2 13 15
  64. # Now ask for a log message, continously add to the log file
  65. (
  66.     echo "Version: $SYMREVNAME($SYMREV), Date: $DATE
  67. -----------" || exit
  68.     while read MESS
  69.     do
  70.         case $MESS in
  71.         .) break
  72.         esac
  73.         echo "    $MESS" || exit
  74.     done
  75.     echo "-----------
  76. " &&
  77.     cat $LOGFILE
  78. ) >$TMPLOG &&
  79.  
  80. # combine old and new logfiles
  81. cp $TMPLOG $LOGFILE &&
  82. rm -f $TMPLOG || exit
  83. trap 1 2 13 15
  84.  
  85. # Now the real work begins by assigning a symbolic revision number
  86. # to each rcs file. Take the most recent version of the main trunk.
  87.  
  88. status=
  89.  
  90. for FILE in ${RCSDIR}*
  91. do
  92. #   get the revision number of the most recent revision
  93.     HEAD=`rlog -h $FILE` &&
  94.     REV=`echo "$HEAD" | sed -n 's/^head:[     ]*//p'` &&
  95. #   assign symbolic name to it.
  96.     echo >&2 "rcsfreeze: $REV $FILE" &&
  97.     rcs -q -n$SYMREVNAME:$REV $FILE || status=$?
  98. done
  99.  
  100. exit $status
  101.